package com.lzq.model.visitor.dynamicdispatch;

/**
 * @author : modify
 * @version : v1.0
 * @description :
 * @createTime : 2022/11/29 15:11
 * @updateUser : modify
 * @updateTime : 2022/11/29 15:11
 * @updateRemark : 动态分派
 */
public class Dynamic {
    public static void main(String[] args) {
        Animal a = new Dog();
        a.execute();

        Animal a1 = new Cat();
        a1.execute();
    }
}

class Animal {
    public void execute() {
        System.out.println("Animal");
    }
}

class Dog extends Animal {
    @Override
    public void execute() {
        System.out.println("dog");
    }
}

class Cat extends Animal {
    @Override
    public void execute() {
        System.out.println("cat");
    }
}